﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>成绩编辑</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- Le styles -->
    <link href="./css/bootstrap.min.css" rel="stylesheet">
    <style type="text/css">
        body
        {
            padding-top: 60px;
            padding-bottom: 40px;
        }
        .sidebar-nav
        {
            padding: 9px 0;
        }
        
        @media (max-width: 980px)
        {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right
            {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }
    </style>
    <link href="./css/bootstrap-responsive.min.css" rel="stylesheet">
    <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="//cdnjs.bootcss.com/ajax/libs/html5shiv/3.6.2/html5shiv.js"></script>
    <![endif]-->
    <!-- Fav and touch icons -->
    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="../assets/ico/apple-touch-icon-144-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="../assets/ico/apple-touch-icon-114-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="../assets/ico/apple-touch-icon-72-precomposed.png">
    <link rel="apple-touch-icon-precomposed" href="../assets/ico/apple-touch-icon-57-precomposed.png">
    <link rel="shortcut icon" href="../assets/ico/favicon.png">
</head>
<body>
    <div id="menu-top" class="navbar navbar-inverse navbar-fixed-top">
        <div class="navbar-inner">
            <div class="container-fluid">
                <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                    <span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar">
                    </span>
                </button>
                <a class="brand" href="#">学生成绩管理系统</a>
                <div class="nav-collapse collapse">
                    <p class="navbar-text pull-right">
                        Logged in as <a href="#" class="navbar-link">Username</a>
                    </p>
                    <ul class="nav" id="mainMenu">
                    </ul>
                </div>
                <!--/.nav-collapse -->
            </div>
        </div>
    </div>
    <div id="main" class="container-fluid">
        <div class="row-fluid">
            <div id="main-left" class="span3">
                <div class="well sidebar-nav">
                    <ul class="nav nav-list">
                        <li class="nav-header" id="sideTitle">成绩录入</li>
                        <li class="active"><a href="#singleAdd">单次考试成绩录入</a></li>
                        <li><a href="#classAdd">课程所有考试成绩录入</a></li>
                    </ul>
                </div>
                <!--/.well -->
            </div>
            <!--/span-->
            <div id="main-right" class="span9">
                <section id="singleAdd">
                <div class=" hero-unit" >
                 <div id="Div1" class="">
                        <legend class="">单次考试成绩录入</legend>
                    </div>
                <form class="form-inline">
                <label>
                    课程：</label>
                <select id="select-course">
                   
                </select>
                <label>
                    考试：</label>
                <select id="select-exzam">
                </select>
              
                <button id="button_getScoreList" class="btn btn-success">
                    确定</button>
                </form>
            </div>
            </section>
                <section id="classAdd"> 
              <div class=" hero-unit" >
                 <table id="table_scoreList" class="table table-hover">
                    
                    
                </table>
                <button id="button_scoreEdit" type="submit" class="btn  btn-success">
                    保存</button>
                <button type="cancel" class="btn btn-success">
                    清空</button>
            </div>
                    </section>
            </div>
            <div class="row-fluid">
            </div>
            <!--/row-->
        </div>
        <!--/span-->
    </div>
    <!--/row-->
    <hr>
    <footer>
        <p>&copy; Company 2013</p>
      </footer>
    </div><!--/.fluid-container-->
    <!-- Le javascript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="./js/jquery.js"></script>
    <script src="./js/bootstrap.min.js"></script>
    <script src="js/mainMenu.js" type="text/javascript"></script>
        <script src="js/messenger.js" type="text/javascript"></script>
    <link href="css/messenger.css" rel="stylesheet" type="text/css" />
    <link href="css/messenger-theme-future.css" rel="stylesheet" type="text/css" />
    <script>
    //获取考试列表，添加分数
        var term = "2013下";
        var techid = "1";
        getConditByParams(
            { 'action': 'getCourseByTechTerm',
                'term': term,
                'techid': techid
            },
            {
                selectid: "select-course",
                idcolum: "actualceid",
                name: "coursename"
            },
              function () {
                  var courseid = $("#select-course").val();
                  getConditByParams(
            { 'action': 'getExzamByCourseTech',
                'courseid': courseid,
                'techid': techid
            },
            {
                selectid: "select-exzam",
                idcolum: "exzamid",
                name: "name"
            },
              function () { }
              );
              }
              );
        $("#button_getScoreList").click(function () {
            var exzamid = $('#select-exzam').val();
            $.post("./handler/ScoreHandler.ashx",
            { 'action': 'getScoreListByExzam', 'exzamid': exzamid },
            function (jsondata, status) {
                var column = ['stdid', 'name', 'score'];
                tableNullCreate("table_scoreList", column);

                var table = $("#table_scoreList");
                var content = "";
                content += "<tbody>";
                $(jsondata.Table).each(function (i, item) {
                    console.log("i:" + i);
                    content += "<tr>";
                    content += "<td>" + item[column[0]] + "</td>";
                    content += "<td>" + item[column[1]] + "</td>";
                    content += "<td><input type='text' " + item[column[2]] + "/></td>";
                    content += "</tr>";
                });
                content += "</tbody>";
                table.append(content);
                $("#table_scoreList input").blur(function () {
                    var score = $(this).val();
                    var stdid = $(this).parent().parent().children().first().text();
                    var exzamid = $('#select-exzam').val();
                    if (score.trim() == "" || stdid.trim() == "" || exzamid.trim() == "") {
                        return;
                    }
                    var params = {
                        'action': 'addScoreRow',
                        'exzamid': exzamid,
                        'stdid': stdid,
                        'score': score
                    };
                    $.post("./handler/ScoreHandler.ashx", params, function (data, status) {
                        $.globalMessenger().post("更新成功");
                    });
                });

            }, 'json');
        });
    </script>
    <script>

        $("#button_scoreEdit").click(function () {
            //            var scorelist = "[";
            //            $("#table_scoreList tbody tr").each(function (i, item) {
            //                            scorelist += "{stdid:";
            //                scorelist += $(item).children().eq(0).text();
            //                scorelist += ",score:";
            //                scorelist += $(item).find('input').val();
            //                scorelist += "},";
            //            });
            //            scorelist = scorelist.substr(0, scorelist.length - 1);
            //            scorelist += "]";
            //            scorelist = eval(scorelist);
            var params = {
                'action': 'addScoreList',
                'exzamid': $("#select-exzam").val(),
                'scorelist': scorelist
            };
            $.post("./handler/ScoreHandler.ashx", params, function (data, status) {

            });
        });
    </script>
</body>
</html>
